package com.zhitan.ems.app.api.patrol;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhitan.ems.app.patrol.entity.PatrolNavEntity;
import com.zhitan.ems.app.patrol.service.PatrolNavService;
import com.zhitan.ems.app.patrol.vo.PatrolNavVO;
import com.zhitan.ems.app.patrol.wrapper.PatrolNavWrapper;
import com.zhitan.ems.common.core.domain.R;
import com.zhitan.ems.common.utils.StringUtils;
import com.zhitan.ems.framework.core.vo.VPage;
import com.zhitan.ems.framework.core.vo.VQueryKit;
import com.zhitan.ems.mini.api.ApiBaseAction;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Api(tags = "App管理--导航", value = "导航")
@RestController
@RequestMapping("api/nav")
public class ApiPatrolNavController extends ApiBaseAction{
    @Autowired
    private PatrolNavService patrolNavService;
    @ApiOperation(value = "导航列表", response = VPage.class)
    @GetMapping("/browse")
    public R<List<PatrolNavEntity>> browse(@RequestParam Map<String, Object> params){
         QueryWrapper<PatrolNavEntity> queryWrapper=VQueryKit.getQueryWrapperByMap(params,Arrays.asList("name"), PatrolNavEntity.class);
         queryWrapper.orderByDesc("nav_sort");
         queryWrapper.like(StringUtils.isNotNull(params.get("name")),"name", params.get("name"));
         List<PatrolNavEntity> list = patrolNavService.list(queryWrapper);
        return R.data(list);
    }
    @ApiOperation(value = "信息", response = PatrolNavVO.class)
    @GetMapping("/detail/{id}")
    public R<PatrolNavVO> detail(@PathVariable("id") Long id){
		PatrolNavEntity patrolNav = patrolNavService.getById(id);
	    return R.data(PatrolNavWrapper.build().entityVO(patrolNav));
    }
}
